<template>
  <div class="card" style="width: 100%; height: 100%">
    <el-container style="width: 100%; height: 100%">
      <el-aside style="width: 400px; height: 100%">
        <el-form ref="ruleFormRef" :model="slaDtlFormData" style="width: 100%" label-width="120px">
          <el-form-item label="SLA名称 :" prop="contractName">
            <el-input type="text" v-model="slaDtlFormData.contractName" disabled />
          </el-form-item>
          <el-form-item label="服务机构 :" prop="serviceOrgName">
            <el-input type="text" v-model="slaDtlFormData.serviceOrgName" disabled />
          </el-form-item>
          <el-form-item label="SLA版本 :" prop="versionNumber">
            <el-input type="text" v-model="slaDtlFormData.versionNumber" disabled />
          </el-form-item>
          <el-form-item label="开始时间 :">
            <el-input type="text" v-model="slaDtlFormData.beginTime" disabled />
          </el-form-item>
          <el-form-item label="结束时间 :">
            <el-input type="text" v-model="slaDtlFormData.endTime" disabled />
          </el-form-item>
          <el-form-item label="服务承诺 :" prop="agreement">
            <el-input type="text" v-model="slaDtlFormData.agreement" disabled />
          </el-form-item>
        </el-form>
      </el-aside>
      <el-main>
        <el-tabs v-model="activeName" @tab-click="handleClickTab">
          <div v-auth="'slaRuleView'">
            <el-tab-pane label="服务水平" name="first">
              <ProTable
                ref="serviceProTable"
                :columns="serviceColumns"
                :request-api="getServiceTableList"
                :init-param="initServiceParam"
                :data-callback="ServiceDataCallback"
              >
                <!-- 表格 header 按钮 -->
                <template #tableHeader="scope">
                  <el-button type="primary" v-auth="'slaRuleAdd'" :icon="CirclePlus" @click="addService('新增')">新增</el-button>
                  <el-button type="primary" v-auth="'slaRuleEdit'" :icon="Edit" @click="editService(scope.selectedList)">
                    编辑
                  </el-button>
                  <el-button
                    type="danger"
                    v-auth="'slaRuleDelete'"
                    :icon="Delete"
                    plain
                    @click="deleteService(scope.selectedList)"
                  >
                    删除
                  </el-button>
                  <!--  <el-button v-auth="'batchAdd'" type="primary" :icon="Upload" plain @click="batchAdd">批量添加客户</el-button>
						    <el-button v-auth="'export'" type="primary" :icon="Download" plain @click="downloadFile">导出用户数据</el-button>
						    <el-button type="danger" :icon="Delete" plain @click="batchDelete(scope.selectedList)"> 批量删除用户 </el-button> -->
                </template>
              </ProTable>
              <el-dialog title="新增/编辑服务水平" v-model="dialogServiceTableVisible">
                <div :style="{ height: '500px' }">
                  <el-tabs v-model="ServiceTabsName" class="card" style="width: 100%; height: 500px">
                    <el-tab-pane label="SLA明细" name="first">
                      <el-form ref="ruleFormRef" :model="addServiceFormData" style="width: 100%" label-width="180px">
                        <el-form-item label="SLA名称 :" prop="ruleName">
                          <el-input v-model="addServiceFormData.ruleName" />
                        </el-form-item>
                        <el-form-item label="执行次序(数值大先执行) :" prop="salience">
                          <el-select v-model="addServiceFormData.salience" placeholder="Select">
                            <el-option v-for="item in 100" :key="item - 1" :label="item - 1" :value="item - 1" />
                          </el-select>
                        </el-form-item>
                        <el-form-item label="响应时间 :" prop="versionNumber">
                          <el-input-number v-model="addServiceFormData.rday" :min="0" :max="99999" />天
                          <el-input-number v-model="addServiceFormData.rhour" :min="0" :max="24" />小时
                          <el-input-number v-model="addServiceFormData.rminute" :min="0" :max="60" />分钟
                        </el-form-item>
                        <el-form-item label="完成时间 :">
                          <el-input-number v-model="addServiceFormData.fday" :min="0" :max="99999" />天
                          <el-input-number v-model="addServiceFormData.fhour" :min="0" :max="24" />小时
                          <el-input-number v-model="addServiceFormData.fminute" :min="0" :max="60" />分钟
                        </el-form-item>
                        <el-form-item label="响应率 :" prop="agreement">
                          <el-input-number v-model="addServiceFormData.responseRate" :min="0" :max="100" />百分比（%）
                        </el-form-item>
                        <el-form-item label="完成率 :" prop="isDefault">
                          <el-input-number v-model="addServiceFormData.completeRate" :min="0" :max="100" />百分比（%）
                        </el-form-item>
                        <el-form-item label="完全按自然时间计算 :" prop="isDefault">
                          <el-radio v-model="addServiceFormData.includeHolidayLable" label="true">是</el-radio>
                          <el-radio v-model="addServiceFormData.includeHolidayLable" label="false">否</el-radio>
                        </el-form-item>
                      </el-form>
                    </el-tab-pane>
                    <!--  const constraint=reactive({
								  		conNo:"",
								  		propertyNameLable: "",
								  		propertyName: "",
								  		propertyValue: "",
								  		propertyValueName: "",
								  		dataType: "",
								  		andOr: "",
								  		sequence: 1
								  }) -->
                    <el-tab-pane label="匹配规则" name="second" style="width: 100%" label-width="120px">
                      <el-form :model="constraint" style="width: 360" label-width="150px">
                        <el-form-item class="item" label="规则详细 :">
                          <el-select
                            v-model="constraint.beforePropertyName"
                            style="width: 130px"
                            placeholder="Select"
                            size="large"
                            @change="beforePropertyNameChange"
                          >
                            <el-option
                              v-for="item in serviceRuleOptions"
                              :key="item.value"
                              :label="item.label"
                              :value="item.value"
                            />
                          </el-select>
                          <el-select
                            v-if="
                              constraint.beforePropertyName == `etitle` ||
                              constraint.beforePropertyName == `edesc` ||
                              constraint.beforePropertyName == `processKey`
                            "
                            v-model="constraint.afterPropertyName"
                            style="width: 130px"
                            placeholder="Select"
                            size="large"
                          >
                            <el-option
                              v-for="item in conditionOptionsAll"
                              :key="item.value"
                              :label="item.label"
                              :value="item.value"
                            />
                          </el-select>
                          <el-select
                            v-if="
                              constraint.beforePropertyName != `etitle` &&
                              constraint.beforePropertyName != `edesc` &&
                              constraint.beforePropertyName != `processKey`
                            "
                            v-model="constraint.afterPropertyName"
                            style="width: 130px"
                            placeholder="Select"
                            size="large"
                          >
                            <el-option
                              v-for="item in conditionOptions"
                              :key="item.value"
                              :label="item.label"
                              :value="item.value"
                            />
                          </el-select>
                          <div v-if="constraint.beforePropertyName == `etitle` || constraint.beforePropertyName == `edesc`">
                            <el-input v-model="constraint.propertyValueName" />
                          </div>
                          <div v-if="constraint.beforePropertyName == `createdByNo`">
                            <el-input v-model="constraint.propertyValueName" @click="dialogRuleRequestNoTableVisible = true" />
                            <el-dialog title="选择用户" v-model="dialogRuleRequestNoTableVisible">
                              <div :style="{ height: '500px' }">
                                <Userselect @send-data="sendRuleRequestNoData" />
                              </div>
                            </el-dialog>
                          </div>
                          <div
                            v-if="
                              constraint.beforePropertyName == `priorityNo` ||
                              constraint.beforePropertyName == `seriousnessNo` ||
                              constraint.beforePropertyName == `effectRangeNo` ||
                              constraint.beforePropertyName == `levelNo` ||
                              constraint.beforePropertyName == `imodeNo` ||
                              constraint.beforePropertyName == `requestCategoryNo` ||
                              constraint.beforePropertyName == `organizationNos` ||
                              constraint.beforePropertyName == `cicategoryNos` ||
                              constraint.beforePropertyName == `serviceDirIds` ||
                              constraint.beforePropertyName == `technologyGroup` ||
                              constraint.beforePropertyName == `locationNos`
                            "
                          >
                            <el-tree-select
                              style="width: 180px"
                              v-model="prioritySelectValue"
                              :data="prioritySelectList"
                              multiple
                              :render-after-expand="false"
                              show-checkbox
                              check-strictly
                              check-on-click-node
                            />
                          </div>
                          <div v-if="constraint.beforePropertyName == `processKey`">
                            <el-tree-select
                              style="width: 180px"
                              v-model="prioritySelectValue"
                              :data="prioritySelectList"
                              :render-after-expand="false"
                              show-checkbox
                              check-strictly
                              check-on-click-node
                            />
                          </div>
                          <div v-if="constraint.beforePropertyName == `companyNo`">
                            <el-input v-model="constraint.propertyValueName" @click="dialogRuleCompanyNoTableVisible = true" />
                            <el-dialog title="选择客户" v-model="dialogRuleCompanyNoTableVisible">
                              <div :style="{ height: '500px' }">
                                <Custemerselect @send-data="sendRuleCompanyNoData" />
                              </div>
                            </el-dialog>
                          </div>
                          <el-button type="primary" @click="addRule"> 添加 </el-button>
                        </el-form-item>
                        <el-form-item class="item" label="连接方式 :">
                          <el-radio v-model="constraint.andOr" label="and">and</el-radio>
                          <el-radio v-model="constraint.andOr" label="or">or</el-radio>
                        </el-form-item>
                      </el-form>
                      <ProTable
                        ref="ruleProTable"
                        row-key="id"
                        :indent="20"
                        :data="constraintsList"
                        :columns="ruleColumns"
                        :search-col="{ xs: 1, sm: 1, md: 2, lg: 3, xl: 3 }"
                      >
                        <!-- 表格操作 -->
                        <template #operation="scope">
                          <el-button type="primary" link @click="toUp(scope.$index)">上移</el-button>
                          <el-button type="primary" link @click="toDown(scope.$index)">下移</el-button>
                          <el-button type="primary" link @click="deleteRule(scope.$index)">删除</el-button>
                        </template>
                      </ProTable>
                    </el-tab-pane>
                  </el-tabs>
                </div>
                <el-button type="primary" @click="onSubmitService()"> 保存 </el-button>
              </el-dialog>
            </el-tab-pane>
          </div>
          <div v-auth="'autoUpdate'">
            <el-tab-pane label="自动升级" name="second">
              <ProTable
                ref="autoPromoteProTable"
                :columns="autoPromoteColumns"
                :request-api="getautoPromoteTableList"
                :init-param="initautoPromoteParam"
                :data-callback="autoPromoteDataCallback"
                :request-auto="true"
              >
                <!-- 表格 header 按钮 -->
                <template #tableHeader="scope">
                  <el-button type="primary" :icon="CirclePlus" @click="addautoPromote('新增')">新增</el-button>
                  <el-button type="primary" :icon="Edit" @click="editautoPromote(scope.selectedList)">编辑</el-button>
                  <el-button type="danger" :icon="Delete" plain @click="deleteautoPromote(scope.selectedList)">删除 </el-button>
                  <!--  <el-button v-auth="'batchAdd'" type="primary" :icon="Upload" plain @click="batchAdd">批量添加客户</el-button>
						       <el-button v-auth="'export'" type="primary" :icon="Download" plain @click="downloadFile">导出用户数据</el-button>
						       <el-button type="danger" :icon="Delete" plain @click="batchDelete(scope.selectedList)"> 批量删除用户 </el-button> -->
                </template>
              </ProTable>
              <el-dialog title="新增/编辑自动升级" v-model="dialogAddautoPromoteVisible">
                <div :style="{ height: '360px' }">
                  <el-form :model="autoPromoteAddFormData" style="width: 100%" label-width="120px">
                    <el-form-item label="策略名称 :" prop="ruleName">
                      <el-input v-model="autoPromoteAddFormData.ruleName" />
                    </el-form-item>
                    <el-form-item label="升级依据 :" prop="isDefault">
                      <el-radio v-model="autoPromoteAddFormData.referType" label="response">请求响应</el-radio>
                      <el-radio v-model="autoPromoteAddFormData.referType" label="complete">处理完成</el-radio>
                    </el-form-item>
                    <el-form-item label="升级方式 :" prop="isDefault">
                      <el-radio v-model="autoPromoteAddFormData.beforeOrAfterLable" label="true">逾期后升级</el-radio>
                      <el-radio v-model="autoPromoteAddFormData.beforeOrAfterLable" label="false">逾期前升级</el-radio>
                    </el-form-item>
                    <el-form-item label="升级时间 :" prop="versionNumber">
                      <el-input-number v-model="autoPromoteAddFormData.promoteRuleDay" :min="0" :max="99999" />天
                      <el-input-number v-model="autoPromoteAddFormData.promoteRuleHour" :min="0" :max="24" />小时
                      <el-input-number v-model="autoPromoteAddFormData.promoteRuleMinute" :min="0" :max="60" />分钟
                    </el-form-item>

                    <el-form-item label="升级到:" prop="ruleName">
                      <el-dialog title="选择用户" v-model="dialogPromoteRuleUserSelectVisible">
                        <div :style="{ height: '500px' }">
                          <Userselect @send-data="sendPromoteRuleUserSelectData" />
                        </div>
                      </el-dialog>
                      <el-input
                        v-model="autoPromoteAddFormData.assigneeName"
                        placeholder="点击选择用户"
                        @click="dialogPromoteRuleUserSelectVisible = true"
                      ></el-input>
                    </el-form-item>
                  </el-form>
                </div>
                <el-button type="primary" @click="onSubmitautoPromote()"> 保存 </el-button>
              </el-dialog>
            </el-tab-pane>
          </div>
          <div v-auth="'overdue'">
            <el-tab-pane label="SLA逾期通知技术员" name="third">
              <ProTable
                ref="SLAyuqiProTable"
                :columns="SLAyuqiColumns"
                :request-api="getSLAyuqiTableList"
                :init-param="initSLAyuqiParam"
                :data-callback="SLAyuqiDataCallback"
              >
                <!-- 表格 header 按钮 -->
                <template #tableHeader="scope">
                  <el-button type="primary" :icon="CirclePlus" @click="addSLAyuqi('新增')">新增</el-button>
                  <el-button type="primary" :icon="Edit" @click="editSLAyuqi(scope.selectedList)">编辑</el-button>
                  <el-button type="danger" :icon="Delete" plain @click="deleteSLAyuqi(scope.selectedList)">删除 </el-button>
                  <!--  <el-button v-auth="'batchAdd'" type="primary" :icon="Upload" plain @click="batchAdd">批量添加客户</el-button>
						       <el-button v-auth="'export'" type="primary" :icon="Download" plain @click="downloadFile">导出用户数据</el-button>
						       <el-button type="danger" :icon="Delete" plain @click="batchDelete(scope.selectedList)"> 批量删除用户 </el-button> -->
                </template>
              </ProTable>
              <el-dialog title="新增/编辑SLA逾期通知技术员" v-model="dialogAddSLAyuqiVisible">
                <div :style="{ height: '260px' }">
                  <el-form :model="SLAyuqiAddFormData" style="width: 100%" label-width="120px">
                    <el-form-item label="通知名称 :" prop="ruleName">
                      <el-input v-model="SLAyuqiAddFormData.ruleName" />
                    </el-form-item>
                    <el-form-item label="通知依据 :" prop="isDefault">
                      <el-radio v-model="SLAyuqiAddFormData.referType" label="response">请求响应</el-radio>
                      <el-radio v-model="SLAyuqiAddFormData.referType" label="complete">处理完成</el-radio>
                    </el-form-item>
                    <el-form-item label="通知方式 :" prop="isDefault">
                      <el-radio v-model="SLAyuqiAddFormData.beforeOrAfterLable" label="true">逾期后通知</el-radio>
                      <el-radio v-model="SLAyuqiAddFormData.beforeOrAfterLable" label="false">逾期前通知</el-radio>
                    </el-form-item>
                    <el-form-item label="通知时间 :" prop="versionNumber">
                      <el-input-number v-model="SLAyuqiAddFormData.promoteRuleDay" :min="0" :max="99999" />天
                      <el-input-number v-model="SLAyuqiAddFormData.promoteRuleHour" :min="0" :max="24" />小时
                      <el-input-number v-model="SLAyuqiAddFormData.promoteRuleMinute" :min="0" :max="60" />分钟
                    </el-form-item>
                  </el-form>
                </div>
                <el-button type="primary" @click="onSubmitSLAyuqi()"> 保存 </el-button>
              </el-dialog>
            </el-tab-pane>
          </div>
        </el-tabs>
      </el-main>
    </el-container>
  </div>
</template>

<script setup lang="ts" name="useProTableDetail">
import { useRoute } from "vue-router";
import { ref, reactive, onMounted } from "vue";
import ProTable from "@/components/ProTable/index.vue";
import { ElMessage, ElMessageBox } from "element-plus";
import { ProTableInstance, ColumnProps, HeaderRenderScope } from "@/components/ProTable/interface";
import {
  findSlaById,
  findSlaRule,
  isSlaNameExist,
  saveSlaRule,
  findPageProcessDefinitions,
  getConfigurationCategoryTreeAllData,
  mergeSlaRule,
  findSLARuleByContractNoAndRuleNo,
  deleteSlaRule,
  findPromoteRulePage,
  savePromoteRule,
  deletePromoteRules,
  mergePromoteRule
} from "@/api/modules/slaProtocolManagement";
import { CirclePlus, Delete, EditPen, Download, Upload, View, Refresh, Edit } from "@element-plus/icons-vue";
import Userselect from "@/views/tools/userselect/index.vue";
import Custemerselect from "@/views/tools/custemerSelect/index.vue";
import { dataDictionaryItemsfindByCode, getCategoryTreeAllData } from "@/api/modules/dataDictionary";
import { getUserDepartment } from "@/api/modules/jggl";
import { ResServiceList } from "@/api/modules/serviceList";
const handleClickTab = (tab: any, event: Event) => {
  //解决自动升级表格不加载问题
  if (tab.props.label == "自动升级") {
    autoPromoteProTable.value?.clearSelection();
    autoPromoteProTable.value?.getTableList();
  }
};
//服务水平部分开始

const serviceRuleOptions = [
  {
    value: "etitle",
    label: "标题"
  },
  {
    value: "edesc",
    label: "描述"
  },
  {
    value: "createdByNo",
    label: "请求人"
  },
  {
    value: "priorityNo",
    label: "优先级"
  },
  {
    value: "seriousnessNo",
    label: "紧急度"
  },
  {
    value: "effectRangeNo",
    label: "影响范围"
  },
  {
    value: "requestCategoryNo",
    label: "分类"
  },
  {
    value: "levelNo",
    label: "级别"
  },
  {
    value: "imodeNo",
    label: "来源"
  },
  {
    value: "organizationNos",
    label: "请求人所属机构"
  },
  {
    value: "processKey",
    label: "流程"
  },
  {
    value: "companyNo",
    label: "请求所属客户"
  },
  {
    value: "cicategoryNos",
    label: "配置项分类"
  },
  {
    value: "serviceDirIds",
    label: "关联服务"
  },
  {
    value: "weekNo",
    label: "创建时间所属星期"
  },
  {
    value: "technologyGroup",
    label: "请求人所属技术组"
  },
  {
    value: "locationNos",
    label: "地点"
  }
];
const conditionOptionsAll = [
  {
    value: "matches",
    label: "包含"
  },
  {
    value: "not matches",
    label: "不包含"
  },
  {
    value: "==",
    label: "等于"
  },
  {
    value: "!=",
    label: "不等于"
  },
  {
    value: "matches start",
    label: "开始字符"
  },
  {
    value: "matches end",
    label: "结束字符"
  }
];
const conditionOptions = [
  {
    value: "in",
    label: "包含"
  },
  {
    value: "notIn",
    label: "不包含"
  }
];
const prioritySelectValue = ref();
const prioritySelectList = ref<any>([]);

const dialogRuleRequestNoTableVisible = ref(false);
const dialogRuleCompanyNoTableVisible = ref(false);
//用户选择子组件弹窗回调方法
const sendRuleRequestNoData = (data: any) => {
  dialogRuleRequestNoTableVisible.value = false;
  constraint.propertyValue = data.userId;
  constraint.propertyValueName = data.fullName;
};
//客户选择子组件弹窗回调方法
const sendRuleCompanyNoData = (data: any) => {
  dialogRuleCompanyNoTableVisible.value = false;
  constraint.propertyValue = data.orgNo;
  constraint.propertyValueName = data.orgName;
};

// ProTable 实例
const serviceProTable = ref<ProTableInstance>();
const ruleProTable = ref<ProTableInstance>();
const initServiceParam = reactive({ contractNo: "" });
const dialogServiceTableVisible = ref(false);
const ServiceTabsName = ref("first");
const serviceColumns = reactive<ColumnProps<ResServiceList>[]>([
  { type: "selection", fixed: "left", width: 70 },
  { prop: "ruleName", label: "名称", sortable: true },
  { prop: "salience", label: "执行次序", sortable: true, width: 260 },
  { prop: "showRespondTime", label: "响应时间", sortable: true, width: 260 },
  { prop: "showFinishTime", label: "完成时间", sortable: true, width: 260 }
]);

const ruleColumns = reactive<ColumnProps<ResServiceList>[]>([
  { prop: "propertyNameLable", label: "条件", sortable: true },
  { prop: "propertyValueName", label: "规则内容", sortable: true, width: 260 },
  { prop: "andOr", label: "连接方式", sortable: true, width: 260 },
  { prop: "operation", label: "操作", fixed: "right", width: 200 }
]);
const getServiceTableList = (params: any) => {
  let newParams = JSON.parse(JSON.stringify(params));
  newParams.page = newParams.pageNum;
  newParams.rows = newParams.pageSize;
  newParams._search = false;
  newParams.sidx = "ruleNo";
  newParams.sord = "desc";
  let query = JSON.parse(JSON.stringify(route.query));
  newParams.contractNo = query.id;
  return findSlaRule(newParams, "", ["_search", "sidx", "sord", "page", "rows", "contractNo"]);
};

const ServiceDataCallback = (data: any) => {
  if (data.data != null) {
    data.data.forEach((child: ResServiceList) => {
      child.showRespondTime = child.showRespondTime.replaceAll("DD", "天").replaceAll("HH", "小时").replaceAll("MM", "分钟");
      child.showFinishTime = child.showFinishTime.replaceAll("DD", "天").replaceAll("HH", "小时").replaceAll("MM", "分钟");
    });
  }
  return {
    list: data.data,
    total: data.totalSize,
    pageNum: data.page,
    pageSize: data.rows
  };
};

const constraintsList = ref<any>([]);

const constraint = reactive({
  beforePropertyName: "etitle",
  afterPropertyName: "matches",
  conNo: "",
  propertyNameLable: "",
  propertyName: "",
  propertyValue: "",
  propertyValueName: "",
  // dataType: "",
  andOr: "and",
  sequence: 1
});

const addServiceFormData = reactive({
  contractNo: "",
  patternBinding: "dto",
  patternType: "RequestDTO",
  rulePatternNo: "",
  rulePackageNo: "4",
  dialect: "mvel",
  dataFlag: 0,
  ruleNo: "",
  ruleName: "",
  salience: 0,
  rday: 0,
  rhour: 0,
  rminute: 0,
  fday: 0,
  fhour: 0,
  fminute: 0,
  responseRate: 0,
  completeRate: 0,
  includeHoliday: false,
  includeHolidayLable: "false"
});

const serviceOption = ref("");

// 新增服务水平
const addService = async (row: string) => {
  addServiceFormData.contractNo = "";
  addServiceFormData.patternBinding = "dto";
  addServiceFormData.patternType = "RequestDTO";
  addServiceFormData.rulePatternNo = "";
  addServiceFormData.rulePackageNo = "4";
  addServiceFormData.dialect = "mvel";
  addServiceFormData.dataFlag = 0;
  addServiceFormData.ruleNo = "";
  addServiceFormData.ruleName = "";
  addServiceFormData.salience = 0;
  addServiceFormData.rday = 0;
  addServiceFormData.rhour = 0;
  addServiceFormData.rminute = 0;
  addServiceFormData.fday = 0;
  addServiceFormData.fhour = 0;
  addServiceFormData.fminute = 0;
  addServiceFormData.responseRate = 0;
  addServiceFormData.completeRate = 0;
  addServiceFormData.includeHoliday = false;
  addServiceFormData.includeHolidayLable = "false";
  serviceOption.value = "add";
  constraintsList.value = [];
  dialogServiceTableVisible.value = true;
};
// 编辑服务水平
const editService = async (row: any[]) => {
  if (row.length != 1) {
    ElMessage.error("请选择一条数据进行编辑");
    return;
  }
  let query = JSON.parse(JSON.stringify(route.query));
  findSLARuleByContractNoAndRuleNo(query.id, row[0]["ruleNo"]).then(res => {
    let newres = JSON.parse(res.toString().replace("},]", "}]"));
    addServiceFormData.contractNo = query.id;
    addServiceFormData.patternBinding = "dto";
    addServiceFormData.patternType = "RequestDTO";
    addServiceFormData.rulePatternNo = newres.rulePatternNo == undefined ? "" : newres.rulePatternNo;
    addServiceFormData.rulePackageNo = "4";
    addServiceFormData.dialect = "mvel";
    addServiceFormData.dataFlag = 0;
    addServiceFormData.ruleNo = newres.ruleNo == undefined ? "" : newres.ruleNo;
    addServiceFormData.ruleName = newres.ruleName == undefined ? "" : newres.ruleName;
    addServiceFormData.salience = newres.salience == undefined ? "" : newres.salience;
    addServiceFormData.rday = newres.rday == undefined ? 0 : newres.rday;
    addServiceFormData.rhour = newres.rhour == undefined ? 0 : newres.rhour;
    addServiceFormData.rminute = newres.rminute == undefined ? 0 : newres.rminute;
    addServiceFormData.fday = newres.fday == undefined ? 0 : newres.fday;
    addServiceFormData.fhour = newres.fhour == undefined ? 0 : newres.fhour;
    addServiceFormData.fminute = newres.fminute == undefined ? 0 : newres.fminute;
    addServiceFormData.responseRate = newres.responseRate == undefined ? 0 : newres.responseRate;
    addServiceFormData.completeRate = newres.completeRate == undefined ? 0 : newres.completeRate;
    addServiceFormData.includeHoliday = newres.includeHoliday == "false" ? false : true;
    addServiceFormData.includeHolidayLable = newres.includeHoliday;
    newres.constraints.forEach(element => {
      let str = element["propertyName"];
      element["propertyNameLable"] = "";
      if ((str as string).match("etitle")) {
        element["propertyNameLable"] += "标题 ";
      }
      if ((str as string).match("edesc")) {
        element["propertyNameLable"] += "描述 ";
      }
      if ((str as string).match("createdByNo")) {
        element["propertyNameLable"] += "请求人 ";
      }
      if ((str as string).match("priorityNo")) {
        element["propertyNameLable"] += "优先级 ";
      }
      if ((str as string).match("seriousnessNo")) {
        element["propertyNameLable"] += "紧急度 ";
      }
      if ((str as string).match("effectRangeNo")) {
        element["propertyNameLable"] += "影响范围 ";
      }
      if ((str as string).match("requestCategoryNo")) {
        element["propertyNameLable"] += "分类 ";
      }
      if ((str as string).match("levelNo")) {
        element["propertyNameLable"] += "级别 ";
      }
      if ((str as string).match("imodeNo")) {
        element["propertyNameLable"] += "来源 ";
      }
      if ((str as string).match("organizationNos")) {
        element["propertyNameLable"] += "请求人所属机构 ";
      }
      if ((str as string).match("processKey")) {
        element["propertyNameLable"] += "流程 ";
      }
      if ((str as string).match("companyNo")) {
        element["propertyNameLable"] += "请求所属客户 ";
      }
      if ((str as string).match("cicategoryNos")) {
        element["propertyNameLable"] += "配置项分类 ";
      }
      if ((str as string).match("serviceDirIds")) {
        element["propertyNameLable"] += "关联服务 ";
      }
      if ((str as string).match("weekNo")) {
        element["propertyNameLable"] += "创建时间所属星期 ";
      }
      if ((str as string).match("technologyGroup")) {
        element["propertyNameLable"] += "请求人所属技术组 ";
      }
      if ((str as string).match("locationNos")) {
        element["propertyNameLable"] += "地点 ";
      }

      if ((str as string).match("matches")) {
        element["propertyNameLable"] += "包含";
      }
      if ((str as string).match("not matches")) {
        element["propertyNameLable"] += "不包含";
      }
      if ((str as string).match("==")) {
        element["propertyNameLable"] += "等于";
      }
      if ((str as string).match("!=")) {
        element["propertyNameLable"] += "不等于";
      }
      if ((str as string).match("matches start")) {
        element["propertyNameLable"] += "开始字符";
      }
      if ((str as string).match("matches end")) {
        element["propertyNameLable"] += "结束字符";
      }
      if ((str as string).match("in")) {
        element["propertyNameLable"] += "包含";
      }
      if ((str as string).match("notIn")) {
        element["propertyNameLable"] += "不包含";
      }
    });
    constraintsList.value = newres.constraints;
  });
  serviceOption.value = "edit";
  dialogServiceTableVisible.value = true;
  // await useHandleData(changeUserStatus, { id: row.id, status: row.status == 1 ? 0 : 1 }, `切换【${row.username}】用户状态`);
  // proTable.value?.getTableList();
};

// 删除服务水平
const deleteService = async (id: any[]) => {
  if (id.length == 0) {
    ElMessage({
      type: "error",
      message: "请选择数据"
    });
    return;
  }
  let NameStr = "";
  let idsStr = "";
  for (let i = 0; i < id.length; i++) {
    if (idsStr == "") {
      idsStr = "?ruleNos=" + id[i].ruleNo;
    } else {
      idsStr = idsStr + "&ruleNos=" + id[i].ruleNo;
    }
    NameStr = NameStr + id[i].ruleName + ",";
  }
  ElMessageBox.confirm("是否删除选中的数据：" + NameStr + " ？", "删除确认", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    type: "warning",
    center: true
  })
    .then(() => {
      deleteSlaRule(idsStr).then(res => {
        ElMessage({
          type: "success",
          message: "删除成功"
        });
        serviceProTable.value?.clearSelection();
        serviceProTable.value?.getTableList();
      });
    })
    .catch(() => {
      ElMessage({
        type: "info",
        message: "取消删除"
      });
    });
};

// 上移
const toUp = async (index: any) => {
  if (index == 0) return;
  constraintsList.value[index] = constraintsList.value.splice(index - 1, 1, constraintsList.value[index])[0];
};
// 下移
const toDown = async (index: any) => {
  if (index === constraintsList.value.length - 1) return;
  // 将上下个数组元素值替换为当前元素值，并将被替换的元素值赋值给当前元素
  constraintsList.value[index] = constraintsList.value.splice(index + 1, 1, constraintsList.value[index])[0];
};
// 删除
const deleteRule = async (index: any) => {
  constraintsList.value.splice(index, 1);
};

//选择条件改变方法
const beforePropertyNameChange = (data: any) => {
  prioritySelectValue.value = [];
  constraint.propertyValueName = "";
  constraint.propertyValue = "";
  if (data != `etitle` && data != `edesc` && data != `processKey`) {
    constraint.afterPropertyName = "in";
  } else {
    constraint.afterPropertyName = "matches";
  }
  if (data == "priorityNo") {
    dataDictionaryItemsfindByCode("priority").then(res => {
      (res as any).forEach(function (element) {
        element["lable"] = element["dname"];
        element["value"] = element["dname"];
      });
      prioritySelectList.value = res as any;
    });
  }
  if (data == "seriousnessNo") {
    dataDictionaryItemsfindByCode("seriousness").then(res => {
      (res as any).forEach(function (element) {
        element["lable"] = element["dname"];
        element["value"] = element["dname"];
      });
      prioritySelectList.value = res as any;
    });
  }
  if (data == "effectRangeNo") {
    dataDictionaryItemsfindByCode("effectRange").then(res => {
      (res as any).forEach(function (element) {
        element["lable"] = element["dname"];
        element["value"] = element["dname"];
      });
      prioritySelectList.value = res as any;
    });
  }
  if (data == "levelNo") {
    dataDictionaryItemsfindByCode("level").then(res => {
      (res as any).forEach(function (element) {
        element["lable"] = element["dname"];
        element["value"] = element["dname"];
      });
      prioritySelectList.value = res as any;
    });
  }
  if (data == "imodeNo") {
    dataDictionaryItemsfindByCode("imode").then(res => {
      (res as any).forEach(function (element) {
        element["lable"] = element["dname"];
        element["value"] = element["dname"];
      });
      prioritySelectList.value = res as any;
    });
  }
  if (data == "requestCategoryNo") {
    getCategoryTreeAllData("Request").then(res => {
      // 使用traverseTree遍历树
      traverseTree(res as any, node => {
        node["lable"] = node.attr.cname;
        node["value"] = node.attr.cname;
      });
      let k: any[] = [];
      k.push(res);
      prioritySelectList.value = k;
    });
  }
  if (data == "organizationNos" || data == "technologyGroup") {
    getUserDepartment().then(res => {
      // 使用traverseTree遍历树
      traverseTree(res[0], node => {
        node.lable = node.attr.orgName;
        node.value = node.attr.orgName;
      });
      prioritySelectList.value = res as any;
    });
  }
  if (data == "processKey") {
    findPageProcessDefinitions().then(res => {
      let newres = JSON.parse(JSON.stringify(res));
      (newres.data as any).forEach(function (element) {
        // let tmp={}
        element["lable"] = element["name"];
        element["value"] = element["name"] + "（Ver:" + element["version"] + ")";
      });
      prioritySelectList.value = newres.data as any;
    });
  }
  if (data == "cicategoryNos") {
    getConfigurationCategoryTreeAllData().then(res => {
      // 使用traverseTree遍历树
      traverseTree(res as any, node => {
        node["lable"] = node.attr.cname;
        node["value"] = node.attr.cname;
      });
      prioritySelectList.value = [res as any];
    });
  }

  if (data == "serviceDirIds") {
    getCategoryTreeAllData("Service").then(res => {
      // 使用traverseTree遍历树
      traverseTree(res as any, node => {
        node["lable"] = node.attr.cname;
        node["value"] = node.attr.cname;
      });
      prioritySelectList.value = [res as any];
    });
  }
  if (data == "weekNo") {
    prioritySelectList.value = [
      {
        lable: "星期一",
        value: "星期一"
      },
      {
        lable: "星期二",
        value: "星期二"
      },
      {
        lable: "星期三",
        value: "星期三"
      },
      {
        lable: "星期四",
        value: "星期四"
      },
      {
        lable: "星期五",
        value: "星期五"
      },
      {
        lable: "星期六",
        value: "星期六"
      },
      {
        lable: "星期天",
        value: "星期天"
      }
    ];
  }

  if (data == "locationNos") {
    getCategoryTreeAllData("Location").then(res => {
      // 使用traverseTree遍历树
      traverseTree(res as any, node => {
        node["lable"] = node.attr.cname;
        node["value"] = node.attr.cname;
      });
      prioritySelectList.value = [res as any];
    });
  }
};
//添加规则
const addRule = async () => {
  //拷贝数据防止指针相同所有数据一起改变 开始
  let tmp = {
    dataType: "String"
  };
  for (let k in constraint) {
    tmp[k] = constraint[k];
  }

  //拷贝数据防止指针相同所有数据一起改变 结束
  if (tmp["beforePropertyName"] == `etitle`) {
    if (tmp["propertyValueName"] == "") {
      ElMessage.error("请选择填写值");
      return;
    }
    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName

    tmp.dataType = "String";
    if (tmp["afterPropertyName"] == "matches") {
      tmp["propertyValue"] = ".*" + tmp["propertyValueName"] + ".*";
      tmp["propertyNameLable"] = "标题 包含";
    }
    if (tmp["afterPropertyName"] == "not matches") {
      tmp["propertyValue"] = tmp["propertyValueName"];
      tmp["propertyNameLable"] = "标题 不包含";
    }
    if (tmp["afterPropertyName"] == "==") {
      tmp["propertyValue"] = tmp["propertyValueName"];
      tmp["propertyNameLable"] = "标题 等于";
    }
    if (tmp["afterPropertyName"] == "!=") {
      tmp["propertyValue"] = tmp["propertyValueName"];
      tmp["propertyNameLable"] = "标题 不等于";
    }
    if (tmp["afterPropertyName"] == "matches start") {
      tmp["propertyValue"] = tmp["propertyValueName"] + ".*";
      tmp["propertyNameLable"] = "标题 开始字符";
    }
    if (tmp["afterPropertyName"] == "matches end") {
      tmp["propertyValue"] = ".*" + tmp["propertyValueName"];
      tmp["propertyNameLable"] = "标题 结束字符";
    }
    (constraintsList.value as any).push(tmp);
  }
  if (tmp["beforePropertyName"] == `edesc`) {
    if (tmp["propertyValueName"] == "") {
      ElMessage.error("请选择填写值");
      return;
    }
    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp.dataType = "String";
    if (tmp["afterPropertyName"] == "matches") {
      tmp["propertyValue"] = ".*" + tmp["propertyValueName"] + ".*";
      tmp["propertyNameLable"] = "描述 包含";
    }
    if (tmp["afterPropertyName"] == "not matches") {
      tmp["propertyValue"] = tmp["propertyValueName"];
      tmp["propertyNameLable"] = "描述 不包含";
    }
    if (tmp["afterPropertyName"] == "==") {
      tmp["propertyValue"] = tmp["propertyValueName"];
      tmp["propertyNameLable"] = "描述 等于";
    }
    if (tmp["afterPropertyName"] == "!=") {
      tmp["propertyValue"] = tmp["propertyValueName"];
      tmp["propertyNameLable"] = "描述 不等于";
    }
    if (tmp["afterPropertyName"] == "matches start") {
      tmp["propertyValue"] = tmp["propertyValueName"] + ".*";
      tmp["propertyNameLable"] = "描述 开始字符";
    }
    if (tmp["afterPropertyName"] == "matches end") {
      tmp["propertyValue"] = ".*" + tmp["propertyValueName"];
      tmp["propertyNameLable"] = "描述 结束字符";
    }
    (constraintsList.value as any).push(tmp);
  }

  if (tmp["beforePropertyName"] == `createdByNo`) {
    tmp.dataType = "Long";
    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp["propertyNameLable"] = "请求人 " + (tmp["afterPropertyName"] == "in" ? "包含" : "不包含");
    if (tmp["propertyValue"] == "") {
      ElMessage.error("请选择请求人");
      return;
    }
    (constraintsList.value as any).push(tmp);
  }

  if (tmp["beforePropertyName"] == `priorityNo`) {
    tmp.dataType = "Long";
    if (prioritySelectValue.value.length < 0) {
      ElMessage.error("请选择优先级");
      return;
    }
    tmp["propertyValue"] = "";
    tmp["propertyValueName"] = "";
    prioritySelectList.value.forEach(function (element) {
      let newElement = JSON.parse(JSON.stringify(element));
      prioritySelectValue.value.forEach(function (element2) {
        let newElement2 = JSON.parse(JSON.stringify(element2));
        if (newElement.value == newElement2.toString()) {
          if (tmp["propertyValue"] == "") {
            tmp["propertyValue"] = newElement.dcode;
          } else {
            tmp["propertyValue"] += "," + newElement.dcode;
          }
          if (tmp["propertyValueName"] == "") {
            tmp["propertyValueName"] = newElement.dname;
          } else {
            tmp["propertyValueName"] += "," + newElement.dname;
          }
        }
      });
    });

    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp["propertyNameLable"] = "优先级 " + (tmp["afterPropertyName"] == "in" ? "包含" : "不包含");
    (constraintsList.value as any).push(tmp);
  }

  if (tmp["beforePropertyName"] == `seriousnessNo`) {
    tmp.dataType = "Long";
    if (prioritySelectValue.value.length < 0) {
      ElMessage.error("请选择紧急度");
      return;
    }
    tmp["propertyValue"] = "";
    tmp["propertyValueName"] = "";
    prioritySelectList.value.forEach(function (element) {
      let newElement = JSON.parse(JSON.stringify(element));
      prioritySelectValue.value.forEach(function (element2) {
        let newElement2 = JSON.parse(JSON.stringify(element2));
        if (newElement.value == newElement2.toString()) {
          if (tmp["propertyValue"] == "") {
            tmp["propertyValue"] = newElement.dcode;
          } else {
            tmp["propertyValue"] += "," + newElement.dcode;
          }
          if (tmp["propertyValueName"] == "") {
            tmp["propertyValueName"] = newElement.dname;
          } else {
            tmp["propertyValueName"] += "," + newElement.dname;
          }
        }
      });
    });

    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp["propertyNameLable"] = "紧急度 " + (tmp["afterPropertyName"] == "in" ? "包含" : "不包含");
    (constraintsList.value as any).push(tmp);
  }

  if (tmp["beforePropertyName"] == `effectRangeNo`) {
    tmp.dataType = "Long";
    if (prioritySelectValue.value.length < 0) {
      ElMessage.error("请选择影响范围");
      return;
    }
    tmp["propertyValue"] = "";
    tmp["propertyValueName"] = "";
    prioritySelectList.value.forEach(function (element) {
      let newElement = JSON.parse(JSON.stringify(element));
      prioritySelectValue.value.forEach(function (element2) {
        let newElement2 = JSON.parse(JSON.stringify(element2));
        if (newElement.value == newElement2.toString()) {
          if (tmp["propertyValue"] == "") {
            tmp["propertyValue"] = newElement.dcode;
          } else {
            tmp["propertyValue"] += "," + newElement.dcode;
          }
          if (tmp["propertyValueName"] == "") {
            tmp["propertyValueName"] = newElement.dname;
          } else {
            tmp["propertyValueName"] += "," + newElement.dname;
          }
        }
      });
    });

    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp["propertyNameLable"] = "影响范围 " + (tmp["afterPropertyName"] == "in" ? "包含" : "不包含");
    (constraintsList.value as any).push(tmp);
  }
  if (tmp["beforePropertyName"] == `levelNo`) {
    tmp.dataType = "Long";
    if (prioritySelectValue.value.length < 0) {
      ElMessage.error("请选择级别");
      return;
    }
    tmp["propertyValue"] = "";
    tmp["propertyValueName"] = "";
    prioritySelectList.value.forEach(function (element) {
      let newElement = JSON.parse(JSON.stringify(element));
      prioritySelectValue.value.forEach(function (element2) {
        let newElement2 = JSON.parse(JSON.stringify(element2));
        if (newElement.value == newElement2.toString()) {
          if (tmp["propertyValue"] == "") {
            tmp["propertyValue"] = newElement.dcode;
          } else {
            tmp["propertyValue"] += "," + newElement.dcode;
          }
          if (tmp["propertyValueName"] == "") {
            tmp["propertyValueName"] = newElement.dname;
          } else {
            tmp["propertyValueName"] += "," + newElement.dname;
          }
        }
      });
    });
    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp["propertyNameLable"] = "级别 " + (tmp["afterPropertyName"] == "in" ? "包含" : "不包含");
    (constraintsList.value as any).push(tmp);
  }
  if (tmp["beforePropertyName"] == `imodeNo`) {
    tmp.dataType = "Long";
    if (prioritySelectValue.value.length < 0) {
      ElMessage.error("请选择来源");
      return;
    }
    tmp["propertyValue"] = "";
    tmp["propertyValueName"] = "";
    prioritySelectList.value.forEach(function (element) {
      let newElement = JSON.parse(JSON.stringify(element));
      prioritySelectValue.value.forEach(function (element2) {
        let newElement2 = JSON.parse(JSON.stringify(element2));
        if (newElement.value == newElement2.toString()) {
          if (tmp["propertyValue"] == "") {
            tmp["propertyValue"] = newElement.dcode;
          } else {
            tmp["propertyValue"] += "," + newElement.dcode;
          }
          if (tmp["propertyValueName"] == "") {
            tmp["propertyValueName"] = newElement.dname;
          } else {
            tmp["propertyValueName"] += "," + newElement.dname;
          }
        }
      });
    });
    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp["propertyNameLable"] = "来源 " + (tmp["afterPropertyName"] == "in" ? "包含" : "不包含");
    (constraintsList.value as any).push(tmp);
  }

  if (tmp["beforePropertyName"] == `requestCategoryNo`) {
    tmp.dataType = "Long";
    if (prioritySelectValue.value.length < 0) {
      ElMessage.error("请选择分类");
      return;
    }
    tmp["propertyValue"] = "";
    tmp["propertyValueName"] = "";
    prioritySelectValue.value.forEach(function (element2) {
      traverseTree(prioritySelectList.value[0], node => {
        if (node.value == element2.toString()) {
          if (tmp["propertyValue"] == "") {
            tmp["propertyValue"] = node.attr.id;
          } else {
            tmp["propertyValue"] += "," + node.attr.id;
          }
          if (tmp["propertyValueName"] == "") {
            tmp["propertyValueName"] = node.attr.cname;
          } else {
            tmp["propertyValueName"] += "," + node.attr.cname;
          }
        }
      });
    });
    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp["propertyNameLable"] = "分类 " + (tmp["afterPropertyName"] == "in" ? "包含" : "不包含");
    (constraintsList.value as any).push(tmp);
  }

  if (tmp["beforePropertyName"] == `organizationNos`) {
    tmp.dataType = "Long []";
    if (prioritySelectValue.value.length <= 0) {
      ElMessage.error("请选择请求人所属机构");
      return;
    }
    tmp["propertyValue"] = "";
    tmp["propertyValueName"] = "";
    prioritySelectValue.value.forEach(function (element2) {
      traverseTree(prioritySelectList.value[0], node => {
        if (node.value == element2.toString()) {
          if (tmp["propertyValue"] == "") {
            tmp["propertyValue"] = node.attr.orgNo;
          } else {
            tmp["propertyValue"] += "," + node.attr.orgNo;
          }
          if (tmp["propertyValueName"] == "") {
            tmp["propertyValueName"] = node.attr.orgName;
          } else {
            tmp["propertyValueName"] += "," + node.attr.orgName;
          }
        }
      });
    });
    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp["propertyNameLable"] = "请求人所属机构 " + (tmp["afterPropertyName"] == "in" ? "包含" : "不包含");
    (constraintsList.value as any).push(tmp);
  }

  if (tmp["beforePropertyName"] == `processKey`) {
    tmp.dataType = "String";
    if (prioritySelectValue.value.length <= 0) {
      ElMessage.error("请选择流程");
      return;
    }
    tmp["propertyValue"] = "";
    tmp["propertyValueName"] = "";
    prioritySelectList.value.forEach(function (element) {
      let newElement = JSON.parse(JSON.stringify(element));
      if (newElement.name + "（Ver:" + newElement.version + ")" == prioritySelectValue.value) {
        tmp["propertyValueName"] = prioritySelectValue.value;
        if (tmp["afterPropertyName"] == "matches") {
          tmp["propertyValue"] = ".*" + newElement.id + ".*";
          tmp["propertyNameLable"] = "流程 包含";
        }
        if (tmp["afterPropertyName"] == "not matches") {
          tmp["propertyValue"] = newElement.id;
          tmp["propertyNameLable"] = "流程 不包含";
        }
        if (tmp["afterPropertyName"] == "==") {
          tmp["propertyValue"] = newElement.id;
          tmp["propertyNameLable"] = "流程 等于";
        }
        if (tmp["afterPropertyName"] == "!=") {
          tmp["propertyValue"] = newElement.id;
          tmp["propertyNameLable"] = "流程 不等于";
        }
        if (tmp["afterPropertyName"] == "matches start") {
          tmp["propertyValue"] = newElement.id + ".*";
          tmp["propertyNameLable"] = "流程 开始字符";
        }
        if (tmp["afterPropertyName"] == "matches end") {
          tmp["propertyValue"] = ".*" + newElement.id;
          tmp["propertyNameLable"] = "流程 结束字符";
        }
      }
    });

    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp["propertyNameLable"] = "流程 " + (tmp["afterPropertyName"] == "in" ? "包含" : "不包含");
    (constraintsList.value as any).push(tmp);
  }

  if (tmp["beforePropertyName"] == `companyNo`) {
    tmp.dataType = "Long";
    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp["propertyNameLable"] = "请求所属客户 " + (tmp["afterPropertyName"] == "in" ? "包含" : "不包含");
    if (tmp["propertyValue"] == "") {
      ElMessage.error("请选择所属客户");
      return;
    }
    (constraintsList.value as any).push(tmp);
  }

  if (tmp["beforePropertyName"] == `cicategoryNos`) {
    tmp.dataType = "Long []";
    if (prioritySelectValue.value.length <= 0) {
      ElMessage.error("请选择配置项分类");
      return;
    }
    tmp["propertyValue"] = "";
    tmp["propertyValueName"] = "";

    prioritySelectValue.value.forEach(function (element2) {
      traverseTree(prioritySelectList.value[0], node => {
        if (node.value == element2.toString()) {
          if (tmp["propertyValue"] == "") {
            tmp["propertyValue"] = node.attr.cno;
          } else {
            tmp["propertyValue"] += "," + node.attr.cno;
          }
          if (tmp["propertyValueName"] == "") {
            tmp["propertyValueName"] = node.attr.cname;
          } else {
            tmp["propertyValueName"] += "," + node.attr.cname;
          }
        }
      });
    });

    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp["propertyNameLable"] = "配置项分类 " + (tmp["afterPropertyName"] == "in" ? "包含" : "不包含");
    (constraintsList.value as any).push(tmp);
  }

  if (tmp["beforePropertyName"] == `serviceDirIds`) {
    tmp.dataType = "Long []";
    if (prioritySelectValue.value.length <= 0) {
      ElMessage.error("请选择关联服务");
      return;
    }
    tmp["propertyValue"] = "";
    tmp["propertyValueName"] = "";

    prioritySelectValue.value.forEach(function (element2) {
      traverseTree(prioritySelectList.value[0], node => {
        if (node.data == element2.toString()) {
          if (tmp["propertyValue"] == "") {
            tmp["propertyValue"] = node.attr.id;
          } else {
            tmp["propertyValue"] += "," + node.attr.id;
          }
          if (tmp["propertyValueName"] == "") {
            tmp["propertyValueName"] = node.attr.cname;
          } else {
            tmp["propertyValueName"] += "," + node.attr.cname;
          }
        }
      });
    });

    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp["propertyNameLable"] = "关联服务 " + (tmp["afterPropertyName"] == "in" ? "包含" : "不包含");
    (constraintsList.value as any).push(tmp);
  }

  if (tmp["beforePropertyName"] == `weekNo`) {
    tmp.dataType = "String []";
    if (prioritySelectValue.value.length <= 0) {
      ElMessage.error("请选择所属星期");
      return;
    }
    tmp["propertyValue"] = "";
    tmp["propertyValueName"] = "";
    prioritySelectValue.value.forEach(function (element2) {
      if (element2.toString() == "星期一") {
        if (tmp["propertyValue"] == "") {
          tmp["propertyValue"] = "Monday";
        } else {
          tmp["propertyValue"] += "," + "Monday";
        }
        if (tmp["propertyValueName"] == "") {
          tmp["propertyValueName"] = "星期一";
        } else {
          tmp["propertyValueName"] += "," + "星期一";
        }
      } else if (element2.toString() == "星期二") {
        if (tmp["propertyValue"] == "") {
          tmp["propertyValue"] = "Tuesday";
        } else {
          tmp["propertyValue"] += "," + "Tuesday";
        }
        if (tmp["propertyValueName"] == "") {
          tmp["propertyValueName"] = "星期二";
        } else {
          tmp["propertyValueName"] += "," + "星期二";
        }
      } else if (element2.toString() == "星期三") {
        if (tmp["propertyValue"] == "") {
          tmp["propertyValue"] = "Wednesday";
        } else {
          tmp["propertyValue"] += "," + "Wednesday";
        }
        if (tmp["propertyValueName"] == "") {
          tmp["propertyValueName"] = "星期三";
        } else {
          tmp["propertyValueName"] += "," + "星期三";
        }
      } else if (element2.toString() == "星期四") {
        if (tmp["propertyValue"] == "") {
          tmp["propertyValue"] = "Thursday";
        } else {
          tmp["propertyValue"] += "," + "Thursday";
        }
        if (tmp["propertyValueName"] == "") {
          tmp["propertyValueName"] = "星期四";
        } else {
          tmp["propertyValueName"] += "," + "星期四";
        }
      } else if (element2.toString() == "星期五") {
        if (tmp["propertyValue"] == "") {
          tmp["propertyValue"] = "Friday";
        } else {
          tmp["propertyValue"] += "," + "Friday";
        }
        if (tmp["propertyValueName"] == "") {
          tmp["propertyValueName"] = "星期五";
        } else {
          tmp["propertyValueName"] += "," + "星期五";
        }
      } else if (element2.toString() == "星期六") {
        if (tmp["propertyValue"] == "") {
          tmp["propertyValue"] = "Saturday";
        } else {
          tmp["propertyValue"] += "," + "Saturday";
        }
        if (tmp["propertyValueName"] == "") {
          tmp["propertyValueName"] = "星期六";
        } else {
          tmp["propertyValueName"] += "," + "星期六";
        }
      } else if (element2.toString() == "星期天") {
        if (tmp["propertyValue"] == "") {
          tmp["propertyValue"] = "Sunday";
        } else {
          tmp["propertyValue"] += "," + "Sunday";
        }
        if (tmp["propertyValueName"] == "") {
          tmp["propertyValueName"] = "星期天";
        } else {
          tmp["propertyValueName"] += "," + "星期天";
        }
      } else {
      }
    });
    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp["propertyNameLable"] = "所属星期 " + (tmp["afterPropertyName"] == "in" ? "包含" : "不包含");
    (constraintsList.value as any).push(tmp);
  }

  if (tmp["beforePropertyName"] == `technologyGroup`) {
    tmp.dataType = "Long []";
    if (prioritySelectValue.value.length < 0) {
      ElMessage.error("请选择所属技术组");
      return;
    }
    tmp["propertyValue"] = "";
    tmp["propertyValueName"] = "";
    prioritySelectValue.value.forEach(function (element2) {
      traverseTree(prioritySelectList.value[0], node => {
        if (node.value == element2.toString()) {
          if (tmp["propertyValue"] == "") {
            tmp["propertyValue"] = node.attr.orgNo;
          } else {
            tmp["propertyValue"] += "," + node.attr.orgNo;
          }
          if (tmp["propertyValueName"] == "") {
            tmp["propertyValueName"] = node.attr.orgName;
          } else {
            tmp["propertyValueName"] += "," + node.attr.orgName;
          }
        }
      });
    });

    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp["propertyNameLable"] = "请求人所属技术组 " + (tmp["afterPropertyName"] == "in" ? "包含" : "不包含");
    (constraintsList.value as any).push(tmp);
  }

  if (tmp["beforePropertyName"] == `locationNos`) {
    tmp.dataType = "Long";
    if (prioritySelectValue.value.length <= 0) {
      ElMessage.error("请选择地点");
      return;
    }
    tmp["propertyValue"] = "";
    tmp["propertyValueName"] = "";

    prioritySelectValue.value.forEach(function (element2) {
      traverseTree(prioritySelectList.value[0], node => {
        if (node.value == element2.toString()) {
          if (tmp["propertyValue"] == "") {
            tmp["propertyValue"] = node.attr.id;
          } else {
            tmp["propertyValue"] += "," + node.attr.id;
          }
          if (tmp["propertyValueName"] == "") {
            tmp["propertyValueName"] = node.attr.cname;
          } else {
            tmp["propertyValueName"] += "," + node.attr.cname;
          }
        }
      });
    });
    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp["propertyNameLable"] = "地点 " + (tmp["afterPropertyName"] == "in" ? "包含" : "不包含");
    (constraintsList.value as any).push(tmp);
  }
};

const onSubmitService = async () => {
  if (addServiceFormData.ruleName == "") {
    ElMessage.error("请填写名称");
    ServiceTabsName.value = "first";
    return;
  }
  if (addServiceFormData.rday == 0 && addServiceFormData.rhour == 0 && addServiceFormData.rminute == 0) {
    ElMessage.error("响应时间不能为空");
    ServiceTabsName.value = "first";
    return;
  }
  if (addServiceFormData.fday == 0 && addServiceFormData.fhour == 0 && addServiceFormData.fminute == 0) {
    ElMessage.error("完成时间不能为空");
    ServiceTabsName.value = "first";
    return;
  }
  if (addServiceFormData.completeRate > addServiceFormData.responseRate) {
    ElMessage.error("完成率不能大于响应率");
    ServiceTabsName.value = "first";
    return;
  }
  addServiceFormData.includeHoliday = addServiceFormData.includeHolidayLable == "true" ? true : false;
  let query = JSON.parse(JSON.stringify(route.query));
  addServiceFormData.contractNo = query.id;
  if (serviceOption.value == "add") {
    //新增
    isSlaNameExist(addServiceFormData.ruleName).then(res => {
      if (res.toString() == "false") {
        saveSlaRule(addServiceFormData, "rule", constraintsList.value).then(res => {
          ElMessage.success("保存成功");
          dialogServiceTableVisible.value = false;
          serviceProTable.value?.clearSelection();
          serviceProTable.value?.getTableList();
        });
      } else {
        ElMessage.error("名称已存在");
      }
    });
  } else {
    //编辑
    mergeSlaRule(addServiceFormData, "rule", constraintsList.value).then(res => {
      ElMessage.success("修改成功");
      dialogServiceTableVisible.value = false;
      serviceProTable.value?.clearSelection();
      serviceProTable.value?.getTableList();
    });
  }
};
//服务水平部分结束

//自动升级部分开始
const dialogPromoteRuleUserSelectVisible = ref(false);
//自动升级用户选择子组件弹窗回调方法
const sendPromoteRuleUserSelectData = (data: any) => {
  autoPromoteAddFormData.assigneeNo = data.userId;
  autoPromoteAddFormData.assigneeName = data.fullName;
  dialogPromoteRuleUserSelectVisible.value = false;
};
const autoPromoteAddFormData = reactive({
  assigneeName: "",
  assigneeNo: "",
  ruleName: "",
  referType: "response",
  beforeOrAfterLable: "true",
  beforeOrAfter: true,
  promoteRuleDay: 0,
  promoteRuleHour: 0,
  promoteRuleMinute: 0,
  ruleNo: "",
  contractNo: "",
  ruleType: "promote"
});
const dialogAddautoPromoteVisible = ref(false);
const initautoPromoteParam = reactive({ contractNo: "", ruleType: "" });
const autoPromoteProTable = ref<ProTableInstance>();
const autoPromoteColumns = reactive<ColumnProps<ResServiceList>[]>([
  { type: "selection", fixed: "left", width: 70 },
  { prop: "ruleName", label: "策略名称", sortable: true },
  {
    prop: "beforeOrAfter",
    label: "升级方式",
    width: 260,
    render: scope => (scope.row.beforeOrAfter === true ? "逾期后升级" : "逾期前升级")
  },
  { prop: "timeStr", label: "升级时间", sortable: true, width: 260 }
]);
const getautoPromoteTableList = (params: any) => {
  let newParams = JSON.parse(JSON.stringify(params));
  newParams.page = newParams.pageNum;
  newParams.rows = newParams.pageSize;
  newParams._search = false;
  newParams.sidx = "ruleNo";
  newParams.sord = "desc";
  let query = JSON.parse(JSON.stringify(route.query));
  newParams.contractNo = query.id;
  newParams.ruleType = "promote";
  return findPromoteRulePage(newParams, "", ["_search", "sidx", "sord", "page", "rows", "contractNo", "ruleType"]);
};
const autoPromoteDataCallback = (data: any) => {
  return {
    list: data.data,
    total: data.totalSize,
    pageNum: data.page,
    pageSize: data.rows
  };
};
const autoPromoteOption = ref("");
const addautoPromote = async (row: string) => {
  autoPromoteAddFormData.assigneeNo = "";
  autoPromoteAddFormData.assigneeName = "";
  autoPromoteAddFormData.ruleName = "";
  autoPromoteAddFormData.referType = "response";
  autoPromoteAddFormData.beforeOrAfterLable = "true";
  autoPromoteAddFormData.beforeOrAfter = true;
  autoPromoteAddFormData.promoteRuleDay = 0;
  autoPromoteAddFormData.promoteRuleHour = 0;
  autoPromoteAddFormData.promoteRuleMinute = 0;
  autoPromoteAddFormData.ruleNo = "";
  autoPromoteAddFormData.contractNo = "";
  autoPromoteAddFormData.ruleType = "promote";
  dialogAddautoPromoteVisible.value = true;
  autoPromoteOption.value = "add";
};
// 编辑SLA逾期
const editautoPromote = async (row: any[]) => {
  if (row.length != 1) {
    ElMessage({
      type: "error",
      message: "请选择一条数据进行编辑"
    });
    return;
  }
  let newParams = JSON.parse(JSON.stringify(row[0]));
  let days = Math.floor(newParams.ruleTime / (3600 * 24));
  let hours = Math.floor((newParams.ruleTime % (3600 * 24)) / 3600);
  let minutes = Math.floor((newParams.ruleTime % 3600) / 60);
  autoPromoteAddFormData.ruleName = newParams.ruleName;
  autoPromoteAddFormData.referType = newParams.referType;
  autoPromoteAddFormData.beforeOrAfterLable = newParams.beforeOrAfter == true ? "true" : "false";
  autoPromoteAddFormData.beforeOrAfter = newParams.beforeOrAfter;
  autoPromoteAddFormData.promoteRuleDay = days;
  autoPromoteAddFormData.promoteRuleHour = hours;
  autoPromoteAddFormData.promoteRuleMinute = minutes;
  autoPromoteAddFormData.ruleNo = newParams.ruleNo;
  autoPromoteAddFormData.contractNo = newParams.contractNo;
  dialogAddautoPromoteVisible.value = true;
  autoPromoteOption.value = "edit";
  autoPromoteAddFormData.assigneeNo = "";
  autoPromoteAddFormData.assigneeName = "";
};

// 删除SLA逾期
const deleteautoPromote = async (id: any[]) => {
  if (id.length == 0) {
    ElMessage({
      type: "error",
      message: "请选择数据"
    });
    return;
  }
  let NameStr = "";
  let idsStr = "";
  for (let i = 0; i < id.length; i++) {
    if (idsStr == "") {
      idsStr = "?ruleNos=" + id[i].ruleNo;
    } else {
      idsStr = idsStr + "&ruleNos=" + id[i].ruleNo;
    }
    NameStr = NameStr + id[i].ruleName + ",";
  }
  ElMessageBox.confirm("是否删除选中的数据：" + NameStr + " ？", "删除确认", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    type: "warning",
    center: true
  })
    .then(() => {
      deletePromoteRules(idsStr).then(res => {
        ElMessage({
          type: "success",
          message: "删除成功"
        });
        autoPromoteProTable.value?.clearSelection();
        autoPromoteProTable.value?.getTableList();
      });
    })
    .catch(() => {
      ElMessage({
        type: "info",
        message: "取消删除"
      });
    });
};
const onSubmitautoPromote = async () => {
  if (autoPromoteAddFormData.ruleName == "") {
    ElMessage.error("请填写名称");
    return;
  }
  if (
    autoPromoteAddFormData.promoteRuleDay == 0 &&
    autoPromoteAddFormData.promoteRuleHour == 0 &&
    autoPromoteAddFormData.promoteRuleMinute == 0
  ) {
    ElMessage.error("通知时间不能为空");
    return;
  }
  autoPromoteAddFormData.beforeOrAfter = autoPromoteAddFormData.beforeOrAfterLable == "true" ? true : false;

  let query = JSON.parse(JSON.stringify(route.query));
  autoPromoteAddFormData.contractNo = query.id;
  if (autoPromoteOption.value == "add") {
    autoPromoteAddFormData.ruleNo = "";
    savePromoteRule(autoPromoteAddFormData, "promoteRuleDTO", ["promoteRuleDay", "promoteRuleHour", "promoteRuleMinute"]).then(
      res => {
        ElMessage.success("保存成功");
        dialogAddautoPromoteVisible.value = false;
        autoPromoteProTable.value?.clearSelection();
        autoPromoteProTable.value?.getTableList();
      }
    );
  } else {
    //编辑
    mergePromoteRule(autoPromoteAddFormData, "promoteRuleDTO", ["promoteRuleDay", "promoteRuleHour", "promoteRuleMinute"]).then(
      res => {
        ElMessage.success("修改成功");
        dialogAddautoPromoteVisible.value = false;
        autoPromoteProTable.value?.clearSelection();
        autoPromoteProTable.value?.getTableList();
      }
    );
  }
};
//自动升级部分结束

//slayuqi开始

const SLAyuqiAddFormData = reactive({
  ruleName: "",
  referType: "response",
  beforeOrAfterLable: "true",
  beforeOrAfter: true,
  promoteRuleDay: 0,
  promoteRuleHour: 0,
  promoteRuleMinute: 0,
  ruleNo: "",
  contractNo: "",
  ruleType: "overdue"
});
const dialogAddSLAyuqiVisible = ref(false);
const initSLAyuqiParam = reactive({ contractNo: "", ruleType: "" });
const SLAyuqiProTable = ref<ProTableInstance>();
const SLAyuqiColumns = reactive<ColumnProps<ResServiceList>[]>([
  { type: "selection", fixed: "left", width: 70 },
  { prop: "ruleName", label: "名称", sortable: true },
  {
    prop: "beforeOrAfter",
    label: "通知方式",
    width: 260,
    render: scope => (scope.row.beforeOrAfter === true ? "逾期后通知" : "逾期前通知")
  },
  { prop: "timeStr", label: "SLA到期时间", sortable: true, width: 260 }
]);
const getSLAyuqiTableList = (params: any) => {
  let newParams = JSON.parse(JSON.stringify(params));
  newParams.page = newParams.pageNum;
  newParams.rows = newParams.pageSize;
  newParams._search = false;
  newParams.sidx = "ruleNo";
  newParams.sord = "desc";
  let query = JSON.parse(JSON.stringify(route.query));
  newParams.contractNo = query.id;
  newParams.ruleType = "overdue";
  return findPromoteRulePage(newParams, "", ["_search", "sidx", "sord", "page", "rows", "contractNo", "ruleType"]);
};
const SLAyuqiDataCallback = (data: any) => {
  return {
    list: data.data,
    total: data.totalSize,
    pageNum: data.page,
    pageSize: data.rows
  };
};
const SLAyuqiOption = ref("");
const addSLAyuqi = async (row: string) => {
  SLAyuqiAddFormData.ruleName = "";
  SLAyuqiAddFormData.referType = "response";
  SLAyuqiAddFormData.beforeOrAfterLable = "true";
  SLAyuqiAddFormData.beforeOrAfter = true;
  SLAyuqiAddFormData.promoteRuleDay = 0;
  SLAyuqiAddFormData.promoteRuleHour = 0;
  SLAyuqiAddFormData.promoteRuleMinute = 0;
  SLAyuqiAddFormData.ruleNo = "";
  SLAyuqiAddFormData.contractNo = "";
  SLAyuqiAddFormData.ruleType = "overdue";
  dialogAddSLAyuqiVisible.value = true;
  SLAyuqiOption.value = "add";
};
// 编辑SLA逾期
const editSLAyuqi = async (row: any[]) => {
  if (row.length != 1) {
    ElMessage({
      type: "error",
      message: "请选择一条数据进行编辑"
    });
    return;
  }
  let newParams = JSON.parse(JSON.stringify(row[0]));
  let days = Math.floor(newParams.ruleTime / (3600 * 24));
  let hours = Math.floor((newParams.ruleTime % (3600 * 24)) / 3600);
  let minutes = Math.floor((newParams.ruleTime % 3600) / 60);
  SLAyuqiAddFormData.ruleName = newParams.ruleName;
  SLAyuqiAddFormData.referType = newParams.referType;
  SLAyuqiAddFormData.beforeOrAfterLable = newParams.beforeOrAfter == true ? "true" : "false";
  SLAyuqiAddFormData.beforeOrAfter = newParams.beforeOrAfter;
  SLAyuqiAddFormData.promoteRuleDay = days;
  SLAyuqiAddFormData.promoteRuleHour = hours;
  SLAyuqiAddFormData.promoteRuleMinute = minutes;
  SLAyuqiAddFormData.ruleNo = newParams.ruleNo;
  SLAyuqiAddFormData.contractNo = newParams.contractNo;
  dialogAddSLAyuqiVisible.value = true;
  SLAyuqiOption.value = "edit";
};

// 删除SLA逾期
const deleteSLAyuqi = async (id: any[]) => {
  if (id.length == 0) {
    ElMessage({
      type: "error",
      message: "请选择数据"
    });
    return;
  }
  let NameStr = "";
  let idsStr = "";
  for (let i = 0; i < id.length; i++) {
    if (idsStr == "") {
      idsStr = "?ruleNos=" + id[i].ruleNo;
    } else {
      idsStr = idsStr + "&ruleNos=" + id[i].ruleNo;
    }
    NameStr = NameStr + id[i].ruleName + ",";
  }
  ElMessageBox.confirm("是否删除选中的数据：" + NameStr + " ？", "删除确认", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    type: "warning",
    center: true
  })
    .then(() => {
      deletePromoteRules(idsStr).then(res => {
        ElMessage({
          type: "success",
          message: "删除成功"
        });
        SLAyuqiProTable.value?.clearSelection();
        SLAyuqiProTable.value?.getTableList();
      });
    })
    .catch(() => {
      ElMessage({
        type: "info",
        message: "取消删除"
      });
    });
};
const onSubmitSLAyuqi = async () => {
  if (SLAyuqiAddFormData.ruleName == "") {
    ElMessage.error("请填写名称");
    return;
  }
  if (
    SLAyuqiAddFormData.promoteRuleDay == 0 &&
    SLAyuqiAddFormData.promoteRuleHour == 0 &&
    SLAyuqiAddFormData.promoteRuleMinute == 0
  ) {
    ElMessage.error("通知时间不能为空");
    return;
  }
  SLAyuqiAddFormData.beforeOrAfter = SLAyuqiAddFormData.beforeOrAfterLable == "true" ? true : false;

  let query = JSON.parse(JSON.stringify(route.query));
  SLAyuqiAddFormData.contractNo = query.id;
  if (SLAyuqiOption.value == "add") {
    SLAyuqiAddFormData.ruleNo = "";
    savePromoteRule(SLAyuqiAddFormData, "promoteRuleDTO", ["promoteRuleDay", "promoteRuleHour", "promoteRuleMinute"]).then(
      res => {
        ElMessage.success("保存成功");
        dialogAddSLAyuqiVisible.value = false;
        SLAyuqiProTable.value?.clearSelection();
        SLAyuqiProTable.value?.getTableList();
      }
    );
  } else {
    //编辑
    mergePromoteRule(SLAyuqiAddFormData, "promoteRuleDTO", ["promoteRuleDay", "promoteRuleHour", "promoteRuleMinute"]).then(
      res => {
        ElMessage.success("修改成功");
        dialogAddSLAyuqiVisible.value = false;
        SLAyuqiProTable.value?.clearSelection();
        SLAyuqiProTable.value?.getTableList();
      }
    );
  }
};
//slayuqi结束
export interface resList {
  agreement: string;
  beginTime: string;
  byServicesNos: [1, 2];
  string: string;
  companyNo: number;
  contractName: string;
  contractNo: number;
  dataFlag: number;
  dcode: number;
  dname: string;
  endTime: string;
  isDefault: boolean;
  lastUpdater: string;
  rulePackageNo: number;
  serviceDirNos: [];
  serviceOrgName: string;
  serviceOrgNo: number;
  versionNumber: string;
  orgNo: string;
  orgName: string;
}
const route = useRoute();
const activeName = ref("first");
const slaDtlFormData = reactive({
  contractNo: "",
  contractName: "",
  serviceOrgName: "",
  serviceOrgNo: "",
  isDefaultFlag: "false",
  isDefault: false,
  versionNumber: "",
  beginTime: "",
  endTime: "",
  agreement: ""
});
onMounted(() => {
  //加载信息
  let query = JSON.parse(JSON.stringify(route.query));
  findSlaById(query.id).then(res => {
    let newParams = JSON.parse(JSON.stringify(res));
    slaDtlFormData.contractName = newParams.contractName;
    slaDtlFormData.serviceOrgName = newParams.serviceOrgName;
    slaDtlFormData.serviceOrgNo = newParams.serviceOrgNo;
    slaDtlFormData.isDefaultFlag = newParams.isDefaultFlag;
    slaDtlFormData.versionNumber = newParams.versionNumber;
    slaDtlFormData.beginTime = newParams.beginTime;
    slaDtlFormData.endTime = newParams.endTime;
    slaDtlFormData.agreement = newParams.agreement;
    slaDtlFormData.contractNo = newParams.contractNo;
  });
});

interface TreeNode {
  value: any;
  lable: any;
  children?: TreeNode[];
  id: string;
  name: string;
  attr: any;
  data: any;
}

function traverseTree(node: TreeNode, callback: (node: TreeNode) => void) {
  callback(node);
  if (node.children) {
    node.children.forEach(child => traverseTree(child, callback));
  }
}
</script>
